|
|
"HelveticaFanatic" <nomail@nomail> wrote in message
news:web.4881a293729c10115f60ef1e0@news.povray.org...
> "HelveticaFanatic" <nomail@nomail> wrote:
>> How can I make an animation of a train that follows curves and elevation?
>> Is
>> there anyway to lay track on it, either?
>>
>> Thanks.
>
> Is there an easy method for regulating the spacing? In other words...
> I always use 1 foot scales for my coordinates for ease in designing and
> visualizing, and I need to accelerate the train and keep it going at a
> smooth
> speed. This would necessitate the float for each vector in the spline to
> be how
> many feet from the end of the track. Is there a way to follow the spline
> by
> length along the spline on the clock value? I'm thinking that I just label
> all
> key points as 1, 2, 3, ..., then use a small program to determine the
> distances
> between the key points (make small subdivisions and Pythagorean theorem,
> add it
> up), then output it to a file, change the 1, 2, 3 to the feet? Or is there
> a
> macro for this or some feature all ready?
>
The 'vlength' function calculates the length of a vector, so you can
subtract the coordinates of one position from the coordinates of another,
then use vlength to find the distance between them (in POV-Ray units). It's
generally best to avoid writing to files if you can because there's usually
a performance penalty to pay.
The following example is a complete test scene file. Although it doesn't
contain a camera or objects it writes debug messages into the message
stream. Note that the second test on the #while loop is just to avoid
infinite loops in case you set DistanceTravelled to a length that takes you
off the end of the spline. In your animation you would define
DistanceTravelled based on the clock and your acceleration profile. The very
short #while loop ends when SplineIndex holds the value you seek. You can
increase the accuracy as necessary by reducing the value of Increment.
#declare YourSpline = spline {
cubic_spline
-.25, <0,0,-1>
0.00, <2,0,0>
1.00, <1,0,2>
1.25, <0,0,1>
}
#declare SplineEnd = 1;
#declare DistanceTravelled = 20;
#declare Increment = 0.1;
#declare CumulativeDistance = 0;
#declare SplineIndex = 0;
// Loop through the spline for the required distance
#while (CumulativeDistance < DistanceTravelled & SplineIndex < SplineEnd)
#declare CumulativeDistance =
CumulativeDistance+vlength(YourSpline(SplineIndex+Increment)-YourSpline(SplineIndex));
#declare SplineIndex = SplineIndex + Increment;
// Write some messages to the message stream
#debug concat("SplineIndex: ",str(SplineIndex,3,3),"\n")
#debug concat("CumulativeDistance: ",str(CumulativeDistance,3,3),"\n")
#debug concat("Position Vector:
",vstr(3,YourSpline(SplineIndex),",",3,3),"\n\n")
#end
Chris B.
Post a reply to this message
|
|